﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using HNQXYJ.BLL;
using HNQXYJ.Model;

namespace HNQXYJ
{
    public partial class Login : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void denglu_Click(object sender, ImageClickEventArgs e)
        {
            
            //string userName = this.txtUserName.Text.Trim();
            //string password = this.txtPassword.Text.Trim();

            string userName = "admin";
            string password = "admin";
            try
            {
                bool flage = new UsersBLL().ValidateUser(userName, password);
                if (flage)
                {
                    Users user = new UsersBLL().GetUserByUserName(userName);
                    Session["username"] = user.UserName;
                    Session["ranklevel"] = user.RankLevel;
                    Session["rankname"] = user.RankName;
                    if (user.RankLevel.Length == 1)
                    {
                        Response.Redirect("MainProvince.aspx");//转到省级主页
                    }
                    else if (user.RankLevel.Length == 3)
                    {
                        Response.Redirect("MainCity.aspx");//转到市级主页
                    }
                    else
                    {
                        Response.Redirect("MainCounty.aspx");//转到县级主页
                    }
                }
                else
                {
                     //this.Label1.Text = "用户名或密码错误";
                }
            }
            catch (Exception ex)
            {
                // this.Label1.Text = ex.Message;
                 
            }
        }
    }
}